"""
@File    ：page_checkin_apply_for.py
@Author  ：ixiaodu
@Date    ：2024/5/14
@Desc    ：
"""
import allure
from selenium.webdriver import Keys

from page_element import el_checkin_apply_for
from utils.timer import sleep
from common.page_base import Base


class PageCheckinApplyFor(Base):
    """入住申请页面"""

    def click_checkin_apply_for(self):
        """点击入住申请"""
        self.base_click(el_checkin_apply_for.checkin_apply_for_btn)
        sleep()

    def click_ss_room_use(self):
        """选择宿舍房间用途"""
        self.base_click(el_checkin_apply_for.ss_room_use)
        sleep()

    def click_xfss_room_use(self):
        """选择选房宿舍房间用途"""
        self.base_click(el_checkin_apply_for.xfss_room_use)
        sleep()

    def click_fqf_room_use(self):
        """选择夫妻房房间用途"""
        self.base_click(el_checkin_apply_for.fqf_room_use)
        sleep()

    def click_application_type(self, application_type):
        """选择申请类型"""
        if application_type == "cg":
            self.base_click(el_checkin_apply_for.cg_application_type)
        elif application_type == "yyd":
            self.base_click(el_checkin_apply_for.yyd_application_type)
        elif application_type == "yy":
            self.base_click(el_checkin_apply_for.yy_application_type)
        elif application_type == "zjd":
            self.base_click(el_checkin_apply_for.zjd_application_type)
        elif application_type == "xf_cg":
            self.base_click(el_checkin_apply_for.xf_cg_application_type)
        elif application_type == "xf_yy":
            self.base_click(el_checkin_apply_for.xf_yy_application_type)
        sleep()

    def click_area_btn(self, application_type):
        """点击区域按钮"""
        if application_type == "fqf":
            self.base_click(el_checkin_apply_for.area_btn_fqf)
        else:
            self.base_click(el_checkin_apply_for.area_btn)
        sleep()

    def click_select_area(self):
        """点击选择区域"""
        self.base_click(el_checkin_apply_for.area)
        sleep()

    def click_couple_room_icon(self):
        """点击是否夫妻房图标"""
        self.base_click(el_checkin_apply_for.couple_room_icon)
        sleep()

    def click_couple_room_yes(self):
        """夫妻房选择是"""
        self.base_click(el_checkin_apply_for.couple_room_yes)
        sleep()

    def click_employed_couple_icon(self):
        """点击是否为双职工图标"""
        self.base_click(el_checkin_apply_for.employed_couple_icon)
        sleep()

    def click_employed_couple_yes(self):
        """双职工选择是"""
        self.base_click(el_checkin_apply_for.employed_couple_yes)
        sleep()

    def click_select_member_icon(self):
        """点击选择成员图标"""
        self.base_click(el_checkin_apply_for.select_member_icon)
        sleep()

    def input_select_member_search(self, text):
        """输入成员搜索框"""
        self.base_input(el_checkin_apply_for.select_member_search, text)
        sleep()

    def click_search_btn(self):
        """点击搜索按钮"""
        self.base_click(el_checkin_apply_for.search_btn)
        sleep()

    def click_select_member(self):
        """选择成员"""
        self.base_click(el_checkin_apply_for.select_member)
        sleep()

    def click_certificate_upload(self):
        """上传证件"""
        self.base_click(el_checkin_apply_for.certificate_upload)
        sleep()
        self.processing_image_upload()

    def click_room_icon(self):
        """点击选择房间图标"""
        self.base_click(el_checkin_apply_for.room_icon)
        sleep()

    def click_building(self):
        """点击选择楼栋"""
        self.base_click(el_checkin_apply_for.building)
        sleep()

    def click_floor(self):
        """点击选择楼层"""
        self.base_click(el_checkin_apply_for.floor)
        sleep()

    def click_room(self):
        """点击选择房间"""
        self.base_click(el_checkin_apply_for.room)
        sleep()

    def click_bed_icon(self):
        """点击选择床位图标"""
        self.base_click(el_checkin_apply_for.bed_icon)
        sleep()

    def click_bed(self):
        """点击选择床位"""
        self.base_click(el_checkin_apply_for.bed)
        sleep()

    def click_checkin_start_date(self):
        """选择入住开始时间"""
        self.base_click(el_checkin_apply_for.checkin_start_date)
        self.base_input(el_checkin_apply_for.checkin_start_date, Keys.ENTER)
        sleep()

    def click_checkin_end_date(self):
        """选择入住结束时间"""
        self.base_click(el_checkin_apply_for.checkin_end_date)
        self.base_input(el_checkin_apply_for.checkin_end_date, Keys.ENTER)
        sleep()

    def input_remark(self, text):
        """输入备注信息"""
        self.base_input(el_checkin_apply_for.remark, text)
        sleep()

    def input_username(self, username):
        """输入姓名"""
        self.base_input(el_checkin_apply_for.username, username)
        sleep()

    def input_phone_number(self, phone_number):
        """输入手机号"""
        self.base_input(el_checkin_apply_for.phone_number, phone_number)
        sleep()

    def input_job_number(self, job_number):
        """输入工号"""
        self.base_input(el_checkin_apply_for.job_number, job_number)
        sleep()

    def click_yyd_sex_select(self):
        """点击预约代申请性别"""
        self.base_click(el_checkin_apply_for.yyd_sex_select)
        sleep()

    def click_zjd_sex_select(self):
        """点击直接代申请性别"""
        self.base_click(el_checkin_apply_for.zjd_sex_select)
        sleep()

    def click_male(self):
        """选择男性"""
        self.base_click(el_checkin_apply_for.male)
        sleep()

    def click_female(self):
        """选择女性"""
        self.base_click(el_checkin_apply_for.female)
        sleep()

    def click_submit_btn(self):
        """点击提交按钮"""
        self.base_click(el_checkin_apply_for.submit_btn)
        sleep()

    def click_submit_affirm_btn(self):
        """点击提交确认按钮"""
        self.base_click(el_checkin_apply_for.submit_affirm_btn)
        sleep()

    def get_submit_info(self):
        """获取提交后页面信息"""
        sleep(2)
        return self.base_get_text(el_checkin_apply_for.submit_info)

    def click_checkin_inform(self):
        """点击申请通知已了解"""
        if self.base_is_enabled(el_checkin_apply_for.checkin_inform):
            self.base_click(el_checkin_apply_for.checkin_inform)
            sleep()

    def click_checkin_notice_read(self):
        """点击已读"""
        self.base_click(el_checkin_apply_for.checkin_notice_read)
        sleep()

    def click_checkin_notice_notarize(self):
        """点击入住须知确认"""
        self.base_click(el_checkin_apply_for.checkin_notice_notarize)
        sleep()

    def open_menu(self):
        """打开菜单"""
        self.base_click(el_checkin_apply_for.ceiling_lamp)
        sleep()

    def click_room_change_btn(self):
        """点击换房按钮"""
        self.base_click(el_checkin_apply_for.room_change_btn)
        sleep()

    def click_checkout_btn(self):
        """点击退房按钮"""
        self.base_click(el_checkin_apply_for.checkout_btn)
        sleep()

    def submit_dormitory_cg_checkin(self, text, application_type):
        """提交宿舍类型常规入住申请"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击宿舍房间用途"):
            self.click_ss_room_use()
        with allure.step(f"点击{application_type}申请类型"):
            self.click_application_type(application_type)
        with allure.step("点击区域按钮"):
            self.click_area_btn(application_type)
        with allure.step("点击选择区域"):
            self.click_select_area()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def submit_dormitory_yyd_checkin(self, text, application_type, username, phone_number, job_number):
        """提交宿舍类型预约代申请"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击宿舍房间用途"):
            self.click_ss_room_use()
        with allure.step(f"点击{application_type}申请类型"):
            self.click_application_type(application_type)
        with allure.step("点击区域按钮"):
            self.click_area_btn(application_type)
        with allure.step("点击选择区域"):
            self.click_select_area()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("选择入住开始时间"):
            self.click_checkin_start_date()
        with allure.step("选择入住结束时间"):
            self.click_checkin_end_date()
        with allure.step(f"姓名输入：{username}"):
            self.input_username(username)
        with allure.step(f"手机号输入：{phone_number}"):
            self.input_phone_number(phone_number)
        with allure.step(f"工号输入：{job_number}"):
            self.input_job_number(job_number)
        with allure.step("点击选择性别"):
            self.click_yyd_sex_select()
        with allure.step("选择男性"):
            self.click_male()
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def submit_dormitory_yy_checkin(self, text, application_type):
        """提交宿舍类型预约入住申请"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击宿舍房间用途"):
            self.click_ss_room_use()
        with allure.step(f"点击{application_type}申请类型"):
            self.click_application_type(application_type)
        with allure.step("点击区域按钮"):
            self.click_area_btn(application_type)
        with allure.step("点击选择区域"):
            self.click_select_area()
        with allure.step("选择入住开始时间"):
            self.click_checkin_start_date()
        with allure.step("选择入住结束时间"):
            self.click_checkin_end_date()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def submit_dormitory_zjd_checkin(self, text, application_type, username, phone_number, job_number):
        """提交宿舍类型直接代申请"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击宿舍房间用途"):
            self.click_ss_room_use()
        with allure.step(f"点击{application_type}申请类型"):
            self.click_application_type(application_type)
        with allure.step("点击区域按钮"):
            self.click_area_btn(application_type)
        with allure.step("点击选择区域"):
            self.click_select_area()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step(f"姓名输入：{username}"):
            self.input_username(username)
        with allure.step(f"手机号输入：{phone_number}"):
            self.input_phone_number(phone_number)
        with allure.step(f"工号输入：{job_number}"):
            self.input_job_number(job_number)
        with allure.step("点击选择性别"):
            self.click_zjd_sex_select()
        with allure.step("选择男性"):
            self.click_male()
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def submit_xf_dormitory_cg_checkin(self, text, application_type):
        """提交选房宿舍常规入住申请"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击选房宿舍房间用途"):
            self.click_xfss_room_use()
        with allure.step(f"点击{application_type}申请类型"):
            self.click_application_type(application_type)
        with allure.step("点击区域按钮"):
            self.click_area_btn(application_type)
        with allure.step("点击选择区域"):
            self.click_select_area()
        with allure.step("点击选择房间图标"):
            self.click_room_icon()
        with allure.step("点击选择楼栋"):
            self.click_building()
        with allure.step("点击选择楼层"):
            self.click_floor()
        with allure.step("点击选择房间"):
            self.click_room()
        with allure.step("点击选择床位图标"):
            self.click_bed_icon()
        with allure.step("点击选择床位"):
            self.click_bed()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def submit_xf_dormitory_yy_checkin(self, text, application_type):
        """提交选房宿舍预约入住申请"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击选房宿舍房间用途"):
            self.click_xfss_room_use()
        with allure.step(f"点击{application_type}申请类型"):
            self.click_application_type(application_type)
        with allure.step("点击区域按钮"):
            self.click_area_btn(application_type)
        with allure.step("点击选择区域"):
            self.click_select_area()
        with allure.step("点击选择房间图标"):
            self.click_room_icon()
        with allure.step("点击选择楼栋"):
            self.click_building()
        with allure.step("点击选择楼层"):
            self.click_floor()
        with allure.step("点击选择房间"):
            self.click_room()
        with allure.step("点击选择床位图标"):
            self.click_bed_icon()
        with allure.step("点击选择床位"):
            self.click_bed()
        with allure.step("选择入住开始时间"):
            self.click_checkin_start_date()
        with allure.step("选择入住结束时间"):
            self.click_checkin_end_date()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def submit_couple_room_checkin(self, text, application_type, search):
        """提交夫妻房入住申请"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击夫妻房房间用途"):
            self.click_fqf_room_use()
        with allure.step("点击是否夫妻房图标"):
            self.click_couple_room_icon()
        with allure.step("夫妻房选择是"):
            self.click_couple_room_yes()
        with allure.step("点击是否为双职工图标"):
            self.click_employed_couple_icon()
        with allure.step("双职工选择是"):
            self.click_employed_couple_yes()
        with allure.step("点击选择成员图标"):
            self.click_select_member_icon()
        with allure.step(f"成员搜索框输入{search}"):
            self.input_select_member_search(search)
        with allure.step("点击搜索按钮"):
            self.click_search_btn()
        with allure.step("点击选择成员"):
            self.click_select_member()
        with allure.step("点击区域按钮"):
            self.click_area_btn(application_type)
        with allure.step("点击选择区域"):
            self.click_select_area()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def notarize_checkin(self):
        """确认入住"""
        with allure.step("点击入住申请按钮"):
            self.click_checkin_apply_for()
        with allure.step("点击确认入住按钮"):
            self.click_submit_btn()
        with allure.step("点击确认按钮"):
            self.click_submit_affirm_btn()

    def submit_room_change(self, text):
        """提交换房操作"""
        with allure.step("点击已了解"):
            self.click_checkin_inform()
        with allure.step("勾选已读"):
            self.click_checkin_notice_read()
        with allure.step("点击确认按钮"):
            self.click_checkin_notice_notarize()
        with allure.step("点击打开菜单"):
            self.open_menu()
        with allure.step("点击换房按钮"):
            self.click_room_change_btn()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()

    def submit_room_checkout(self, text):
        """提交退房操作"""
        with allure.step("点击已了解"):
            self.click_checkin_inform()
        with allure.step("勾选已读"):
            self.click_checkin_notice_read()
        with allure.step("点击确认按钮"):
            self.click_checkin_notice_notarize()
        with allure.step("点击打开菜单"):
            self.open_menu()
        with allure.step("点击退房按钮"):
            self.click_checkout_btn()
        with allure.step(f"备注信息输入：{text}"):
            self.input_remark(text)
        with allure.step("点击提交按钮"):
            self.click_submit_btn()
        with allure.step("点击确认提交按钮"):
            self.click_submit_affirm_btn()
